package net.mymilkedeek.ludum.tinythumb.states;

import net.mymilkedeek.ludum.tinythumb.Game;
import org.newdawn.slick.*;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.util.Log;

/**
 * TODO: Write Documentation
 *
 * @author Michael Demey
 */
public class IntroState extends BasicGameState {

    private Animation animation;

    @Override
    public int getID() {
        return Game.S_INTRO;
    }

    private boolean drawTutorial = false;

    @Override
    public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException {
        Log.debug("INTROGAME  - Initializing");
        animation = new Animation(new SpriteSheet("/resources/spritesheets/intro.png", 358, 288), 5000);
    }

    @Override
    public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics) throws SlickException {
        if (drawTutorial) {

            graphics.setColor(Color.white);

            graphics.drawString("Battle Tutorial (shows only once)", 10, 10);
            graphics.drawString("You have two moves per turn.", 10, 30);
            graphics.drawString("1. Thumb 2. Chic", 10, 50);
            graphics.drawString("You select your opponent with the arrows.", 10, 70);
            graphics.drawString("Spacebar to confirm.", 10, 90);
            graphics.drawString("First choice is Thumb", 10, 110);
            graphics.drawString("Second choice is Chic", 10, 130);
            graphics.drawString("There are no random battles (press b)", 10, 150);
            graphics.drawString("You WILL need to have battled", 10, 170);
            graphics.drawString("before fighting any boss", 10, 190);
            graphics.drawString("Enter to continue", 10, 220);

        } else {
            animation.draw(0,0);
        }
    }

    @Override
    public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int i) throws SlickException {
        if ( !drawTutorial ) {
            if ( gameContainer.getInput().isKeyPressed(Input.KEY_SPACE)) {
                drawTutorial = true;
            }
        } else {
            if ( gameContainer.getInput().isKeyPressed(Input.KEY_ENTER)) {
                stateBasedGame.enterState(Game.S_MAIN);
            }
        }
    }
}
